<template>
  <div>
    <el-card>
      <div>
        <ul class="itemList">
          <li class="item">
            <div class="round">1</div>
            <div><span>今日新增用户</span></div>
          </li>
          <li class="item">
            <div class="round">2416</div>
            <div><span>总用户量</span></div>
          </li>
          <li class="item">
            <div class="round">0</div>
            <div><span>新增试题</span></div>
          </li>
          <li class="item">
            <div class="round">1870</div>
            <div><span>总试题量</span></div>
          </li>
          <li class="item">
            <div class="round">0</div>
            <div><span>总刷题量</span></div>
          </li>
          <li class="item">
            <div class="round">0</div>
            <div><span>人均刷题量</span></div>
          </li>
        </ul>
      </div>
    </el-card>
    <el-card>
      <div id="pie" style="width: 100% ;height: 400px;" />
    </el-card>
  </div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  name: 'DataOverview',
  created() {
    this.getUserInfo()
  },
  mounted() {
    this.initPie()
  },
  methods: {
    getUserInfo() {
      this.$store.dispatch('user/getUserInfo')
    },
    initPie() {
      const option = {
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: '访问来源',
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: 20,
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: false
            },
            data: [
              { value: 10, name: 'Searchine' },
              { value: 4, name: 'Union Ads' },
              { value: 3, name: 'Video Ads' },
              { value: 10, name: 'Searchin' },
              { value: 4, name: 'Union Ad' },
              { value: 3, name: 'Video Ad' },
              { value: 10, name: 'Searchi' },
              { value: 4, name: 'Union A' },
              { value: 3, name: 'Video A' },
              { value: 10, name: 'Searche' },
              { value: 4, name: 'Union Ads' },
              { value: 3, name: 'Vdeo Ads' },
              { value: 10, name: 'Searcine' },
              { value: 4, name: 'Union Ads' },
              { value: 3, name: 'Veo Ads' },
              { value: 10, name: 'Serchine' },
              { value: 4, name: 'Union Ads' },
              { value: 3, name: 'Vido Ads' },
              { value: 10, name: 'Searchine' },
              { value: 4, name: 'Union Ads' },
              { value: 3, name: 'Vio Ads' },
              { value: 10, name: 'Searhine' },
              { value: 4, name: 'Union Ads' },
              { value: 3, name: 'VideAds' },
              { value: 10, name: 'Searcine' },
              { value: 4, name: 'nion Ads' },
              { value: 3, name: 'Vieo Ads' },
              { value: 10, name: 'Sarchine' },
              { value: 4, name: 'Union Ads' },
              { value: 3, name: 'Vide Ads' },
              { value: 10, name: 'Sehine' },
              { value: 4, name: 'Union s' },
              { value: 3, name: 'Veo Ads' },
              { value: 3, name: 'VeoAds' },
              { value: 10, name: 'Sine' },
              { value: 4, name: 'Uni Ads' },
              { value: 3, name: 'Vide Ads' },
              { value: 10, name: 'Seine' },
              { value: 4, name: 'Uni s' },
              { value: 3, name: 'Veods' },
              { value: 3, name: 'Vidse Ads' },
              { value: 10, name: 'Sehinee' },
              { value: 4, name: 'Unioen s' },
              { value: 3, name: 'Veo Ads' },
              { value: 3, name: 'VeoAdds' },
              { value: 10, name: 'Sinew' },
              { value: 4, name: 'Uni Adds' },
              { value: 3, name: 'Videq Ads' },
              { value: 10, name: 'Seidne' },
              { value: 4, name: 'Uni ds' },
              { value: 3, name: 'Veodds' },
              { value: 3, name: 'Vide Ads' },
              { value: 10, name: 'Sehnee' },
              { value: 4, name: 'Unien s' },
              { value: 3, name: 'VeoAs' },
              { value: 3, name: 'VeoAdds' },
              { value: 10, name: 'Sin' },
              { value: 4, name: 'UnAdds' },
              { value: 3, name: 'Vid Ads' },
              { value: 10, name: 'Sene' },
              { value: 4, name: 'Unii ds' },
              { value: 3, name: 'Veoddos' }
            ]
          }
        ]
      }
      const myChart = echarts.init(document.getElementById('pie')) // 图标初始化
      myChart.setOption(option) // 渲染页面
      // 随着屏幕大小调节图表
      window.addEventListener('resize', () => {
        myChart.resize()
      })
    }
  }
}
</script>

<style scoped lang="scss">
::v-deep {
  .itemList {
    display: flex;
    justify-content: space-around;
    margin: 0;
    .item {
      list-style: none;
      .round {
        width: 100px;
        height: 100px;
        text-align: center;
        line-height: 100px;
        border: 2px solid green;
        border-radius: 50%;
      }
      span {
        display: inline-block;
        width: 100%;
        text-align: center;
      }
    }
  }
}
</style>
